package test1230am;

public class Test15 {
    public static void main(String[] args) {
        // (15)定义实现m方法：求数组中最小的偶数
        int[] arr = {1,2,3,4,5};
        int min = m(arr);
        System.out.println(min);
    }
    public static int m(int[] arr) {
        int mindouble = m2(arr);
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] % 2 == 0 && arr[i] < mindouble) {
                mindouble = arr[i];
            }
        }
        return mindouble;
    }
    public static int m2(int[] arr) {
        int max = arr[0];
        for (int i = 0; i < arr.length; i++) {
            if (arr[i]>max) {
                max = arr[i];
            }
        }
        return max;
    }
}
